home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-09 | 4.3 KB | 147 lines | [TEXT/KEEN] |
- # $XRef_Full: from one or more source files, build a cross-reference list
- #of all top-level terms. The built-in function "lookup" must be
- #supported by the application calling hAWK (at present this means just
- #EnterAct). For this to work properly when called from EnterAct, you
- #must have a project open, the project must include files which define
- #all the terms you wish to cross-reference (include the toolbox headers
- #in your project if you want toolbox terms cross-referenced), and your
- #dictionary should be up to date.
- #Similar to $XRef, but does not skip over comments and strings, so
- #"spurious" references may result. Presumably, you'll want them.
- #Use "Set variables" when calling this program to specify which kinds
- #of terms to include in the cross-reference. There are eight kinds of
- #terms, and eight corresponding variables that can be set to 0 or 1,
- #eg do_defines=0 means don't include defines, whereas do_defines=1 means
- #include defines.
- #
- #Typically use the “MFS selected files” input option on one or more files.
- #Any other input option is also OK, just ensure an appropriate EnterAct
- #project is open before running this program.
- #
- #The array "skipList" (see "XRef_Full.T") holds a list of common terms to skip over.
- #In large cross-reference jobs it may be NECESSARY to skip the commonest
- #terms to avoid overflowing the list of references.
-
- # User’s Manual references:
- # «hAWK User’s Manual» «F Running hAWK programs»
- # «hAWK User’s Manual» «L 5 Regular expressions»
- # «hAWK User’s Manual» «M 5 Built-in string and file functions»
- # «hAWK User’s Manual» «K 4 Built-in variables»
- # «hAWK User’s Manual» «K 8 Arrays»
- # «hAWK User’s Manual» «N User-defined functions»
- # «hAWK User’s Manual» «P 3 The getline function»
- # «hAWK User’s Manual» «O 3 Output into files»
- # «hAWK User’s Manual» «Q The hAWK function»
-
- BEGIN {
- if (do_defines == 0 && do_variables == 0 && do_functions == 0 &&
- do_enumConsts == 0 && do_typedefs == 0 && do_structs == 0 &&
- do_unions == 0 && do_enums == 0)
- {
- print "Please use the Set variables button"
- print "and select which kinds of term to reference."
- print "Currently all the selector variables are zero."
- exit
- }
- #Generate the actual xref program from the template program
- #First, a couple of arrays to simplify things
- if (do_defines != 0)
- {
- numfor["defines"] = 1
- namefor["defines"] = ": #define"
- }
- if (do_variables != 0)
- {
- numfor["vars"] = 2
- namefor["vars"] = ": variable"
- }
- if (do_functions != 0)
- {
- numfor["funcs"] = 4
- namefor["funcs"] = ": function"
- }
- if (do_enumConsts != 0)
- {
- numfor["enumCs"] = 8
- namefor["enumCs"] = ": enum constant"
- }
- if (do_typedefs != 0)
- {
- numfor["typedefs"] = 16
- namefor["typedefs"] = ": typedef"
- }
- if (do_structs != 0)
- {
- numfor["structs"] = 32
- namefor["structs"] = ": struct tag"
- }
- if (do_unions != 0)
- {
- numfor["unions"] = 64
- namefor["unions"] = ": union tag"
- }
- if (do_enums != 0)
- {
- numfor["enums"] = 128
- namefor["enums"] = ": enum tag"
- }
- templateFile = STDPATH "Drag_on Modules:hAWK programs:" "XRef_Full.T"
- actualFile = STDPATH "Drag_on Modules:hAWK programs:" "XRef_Full.A"
- while (getline < templateFile > 0)
- {
- if (match($0, /##MARK record/))
- {
- ++tLines
- for (i in numfor)
- {
- if (doneIf)
- print "\t\telse if (type == " numfor[i] ") #" namefor[i] > actualFile
- else#First one, omit the else
- print "\t\tif (type == " numfor[i] ") #" namefor[i] > actualFile
- #print defines[$i] = defines[$i] "\t" fIndex "\t" FNR
- print "\t\t\t" i "[$i] = " i "[$i] \"\\t\" fIndex \"\\t\" FNR" > actualFile
- doneIf = 1
- }
- }
- else if (match($0, /##MARK linear/))
- {
- ++tLines
- for (i in numfor)
- {
- print "\tfor (w in " i ")" > actualFile
- print "\t\t{" > actualFile
- print "\t\tlinear[++m] = w \"" namefor[i] "\" " i "[w]" > actualFile
- print "\t\tdelete " i "[w]" > actualFile
- print "\t\t}" > actualFile
- }
- }
- else
- print > actualFile
- }
- if (tLines < 2)#template missing or damaged
- {
- print "The template file"
- print templateFile
- if (!tLines)
- print "is damaged or missing."
- else
- print "is damaged."
- exit
- }
- else
- {
- close(templateFile)
- close(actualFile)
- }
- #TEST
- ##exit
- #Execute the new specific program XRef_Full.A
- argv[x++] = "hAWK"
- argv[x++] = "-f" actualFile
- argv[x++] = "--"
- for (i = 1; i < ARGC; ++i)
- argv[x++] = ARGV[i]
- hAWK(argv)
- }
-
-